package cn.bdqn.t354.mapper;

import cn.bdqn.t354.pojo.SysUser;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
public class SysUserMapperTester {
    @Resource
    SysUserMapper sysUserMapper;

    @Test
    public void testInsert(){
        SysUser sysUser=new SysUser();
        sysUser.setUsrName("大俊");
        sysUser.setUsrPassword("123456");
        sysUser.setUsrRoleId(2L);
        sysUser.setUsrFlag(1);

        int insert = sysUserMapper.insert(sysUser);
        if(insert>0){
            System.out.println("新增成功");
        }else{
            System.out.println("新增失败");
        }
    }

    @Test
    public void testUpdate(){
        SysUser sysUser=new SysUser();
        sysUser.setUsrId(20L);
        sysUser.setUsrName("小姐");

        int update = sysUserMapper.updateById(sysUser);
        if(update>0){
            System.out.println("修改成功");
        }else{
            System.out.println("修改失败");
        }
    }

    @Test
    public void testDelete(){
        int i = sysUserMapper.deleteById(20L);
        if(i>0){
            System.out.println("删除成功");
        }else{
            System.out.println("删除失败");
        }
    }

    @Test
    public void testSelectList(){
        List<SysUser> list = sysUserMapper.selectList(null);
        for (SysUser sysUser : list) {
            System.out.println(sysUser);
        }
    }

    @Test
    public void testSelectById(){
        SysUser sysUser = sysUserMapper.selectById(2L);
        System.out.println(sysUser);
    }
}
